import request from './request'

// 发送验证码
export const sendCode = (phone, purpose) => {
  return request.post('/auth/send_code', { phone, purpose })
}

// 注册
export const register = (phone, code, nickname) => {
  return request.post('/auth/register', { phone, code, nickname })
}

// 验证码登录
export const loginWithCode = (phone, code) => {
  return request.post('/auth/login/code', { phone, code })
}

// 密码登录
export const loginWithPassword = (phone, password) => {
  return request.post('/auth/login/password', { phone, password })
}

// 退出登录
export const logout = () => {
  return request.post('/auth/logout')
}

// 设置密码
export const setPassword = (new_password) => {
  return request.post('/auth/password/set', { new_password })
}

// 修改密码
export const changePassword = (old_password, new_password) => {
  return request.post('/auth/password/change', { old_password, new_password })
}

// 重置密码
export const resetPassword = (phone, code, new_password) => {
  return request.post('/auth/password/reset', { phone, code, new_password })
}

